﻿<cfscript>
/** 
* Senate Frameworks chooseProperty
* 
* @hint "The student's choosed course property object handler." 
*/

component 
	displayname="public.service.handler.chooseProperty" 
	output=false 
	accessors=true 
	{

	/* PROPERTIES */
	property type="boolean" name="Locked" default="false" hint="是否禁止修改";
	property type="boolean" name="Paid" default="false" hint="是否已缴费";
	property type="boolean" name="PrePaid" default="false" hint="是否从预交学费中扣除";

	property type="boolean" name="CETReplace" default="false" hint="是否使用CET成绩替代";

	property type="boolean" name="Charged" default="false" hint="是否已结算";

	/**
	* @hint "初始化对象"
	* 
	* @Locked "是否禁止修改"
	* @Paid "是否已缴费"
	* @PrePaid "是否从预交学费中扣除"
	* @CETReplace "是否使用CET成绩替代"
	* @Charged "是否已结算"
	*/
	public public.service.handler.chooseProperty function init( boolean Locked=false, boolean Paid=false, boolean PrePaid=false,
																boolean CETReplace=false, 
																boolean Charged=false ) output=false {

		setLocked( arguments.Locked );
		setPaid( arguments.Paid );
		setPrePaid( arguments.PrePaid );

		setCETReplace( arguments.CETReplace );
		
		setCharged( arguments.Charged );
		
		return this;
	}
	
	/**
	* @hint "将上述属性转换为属性字符串"
	*/
	public string function stringProperty() output=false {
		
		var prop = "";
		
		/* 执行序列化 */
		if (getLocked()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getPaid()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getPrePaid()) { prop = prop & "1"; } else { prop = prop & "0"; }
		
		if (getCETReplace()) { prop = prop & "1"; } else { prop = prop & "0"; }
		
		if (getCharged()) { prop = prop & "1"; } else { prop = prop & "0"; }
		

		return left(prop & "000000000000000000000000000000", 30);
		
	}
	
	/**
	* @hint "将属性字符串转换为对象属性"
	* 
	* @fString "属性字符串"
	*/
	public void function parseProperty( required string fString ) output=false {
		
		var i = 0;
		
		for (i=1; i <= len(arguments.fString); i++) {
			
			switch (i) {
				
				case 1:
					/* 第1位 是否禁止修改 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setLocked(true); } else { setLocked(false); }
					break;

				case 2:
					/* 第2位 是否已缴费 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setPaid(true); } else { setPaid(false); }
					break;
				
				case 3:
					/* 第3位 是否已预交学费 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setPrePaid(true); } else { setPrePaid(false); }
					break;
				
				case 4:
					/* 第4位 是否使用CET成绩替代 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setCETReplace(true); } else { setCETReplace(false); }
					break;
				
				case 5:
					/* 第5位 是否已结算 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setCharged(true); } else { setCharged(false); }
					break;
				
			}
		}
	}

	
}

</cfscript>